<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>加载公司地图（arcgis服务）</title>
  <link rel="stylesheet" href="../dist/HMap.css" type="text/css">
</head>
<body>
<div id="map"></div>
<script src="../dist/HMap.js"></script>
<script type="text/javascript">
  var cor = [
    {
      "level": 0,
      "resolution": 156543.03392800014,
      "scale": 5.91657527591555E8
    },
    {
      "level": 1,
      "resolution": 78271.51696399994,
      "scale": 2.95828763795777E8
    },
    {
      "level": 2,
      "resolution": 39135.75848200009,
      "scale": 1.47914381897889E8
    },
    {
      "level": 3,
      "resolution": 19567.87924099992,
      "scale": 7.3957190948944E7
    },
    {
      "level": 4,
      "resolution": 9783.93962049996,
      "scale": 3.6978595474472E7
    },
    {
      "level": 5,
      "resolution": 4891.96981024998,
      "scale": 1.8489297737236E7
    },
    {
      "level": 6,
      "resolution": 2445.98490512499,
      "scale": 9244648.868618
    },
    {
      "level": 7,
      "resolution": 1222.992452562495,
      "scale": 4622324.434309
    },
    {
      "level": 8,
      "resolution": 611.4962262813797,
      "scale": 2311162.217155
    },
    {
      "level": 9,
      "resolution": 305.74811314055756,
      "scale": 1155581.108577
    },
    {
      "level": 10,
      "resolution": 152.87405657041106,
      "scale": 577790.554289
    },
    {
      "level": 11,
      "resolution": 76.43702828507324,
      "scale": 288895.277144
    },
    {
      "level": 12,
      "resolution": 38.21851414253662,
      "scale": 144447.638572
    },
    {
      "level": 13,
      "resolution": 19.10925707126831,
      "scale": 72223.819286
    },
    {
      "level": 14,
      "resolution": 9.554628535634155,
      "scale": 36111.909643
    },
    {
      "level": 15,
      "resolution": 4.77731426794937,
      "scale": 18055.954822
    },
    {
      "level": 16,
      "resolution": 2.388657133974685,
      "scale": 9027.977411
    },
    {
      "level": 17,
      "resolution": 1.1943285668550503,
      "scale": 4513.988705
    },
    {
      "level": 18,
      "resolution": 0.5971642835598172,
      "scale": 2256.994353
    },
    {
      "level": 19,
      "resolution": 0.29858214164761665,
      "scale": 1128.497176
    }
  ];
  var resolutions = [];
  for (var i = 0; i < cor.length; i++) {
    resolutions.push(cor[i].resolution);
  }
  var Maps = new HMap.Map();
  Maps.initMap('map', {
    interactions: {
      altShiftDragRotate: true,
      doubleClickZoom: true,
      keyboard: true,
      mouseWheelZoom: true,
      shiftDragZoom: true,
      dragPan: true,
      pinchRotate: true,
      pinchZoom: true,
      zoomDelta: 1, // 缩放增量（默认一级）
      zoomDuration: 500 // 缩放持续时间
    },
    controls: {
      attribution: true,
      attributionOptions: {
        className: 'ol-attribution', // Default
        target: 'attributionTarget',
      },
      rotate: true,
      rotateOptions: {
        className: 'ol-rotate', // Default
        target: 'rotateTarget',
      },
      zoom: true,
      zoomOptions: {
        className: 'ol-zoom', // Default
        target: 'zoomTarget',
      },
      overViewMapVisible: false,
      scaleLineVisible: true
    },
    view: {
      center: [52734278.282496005, 4131815.988112161],
      resolutions: resolutions,
      fullExtent: [-20037507.067161843, -30240971.95838617, 20037507.067161843, 30240971.958386205],
      tileSize: 256,
      origin: [-20037508.342787, 20037508.342787],
      // constrainRotation: false, // 旋转角度约束
      enableRotation: true, // 是否允许旋转
//      extent: [],
//      maxResolution: 0, // 非必须参数
//      minResolution: 0,
//      maxZoom: 19,
//      minZoom: 0,
      projection: 'EPSG:102100',
      rotation: 0,
      zoom: 0, // resolution
      zoomFactor: 2 // 用于约束分变率的缩放因子（高分辨率设备需要注意）
    },
    logo: {},
    baseLayers: [  // 不传时默认加载OSM地图。
      {
        layerName: 'vector',
        isDefault: true,
        layerType: 'TileXYZ',
        opaque: false, //图层是否不透明
        layerUrl: 'http://10.254.123.75:8080/OneMapServer/rest/services/World2ChinaMapBG/MapServer',
        label: { //地图图层是否对应的有标注层
          layerName: 'vectorLabel',
          isDefault: true,
          alias: 'vector',
          layerType: 'TileXYZ',
          layerUrl: 'http://10.254.123.75:8080/OneMapServer/rest/services/World2ChinaMapLabel/MapServer'
        }
      },
      {
        layerName: 'earth',
        layerType: 'TitleWMTS',
        layer: 'img',
        isDefault: false,
        layerUrl: 'http://t{0-6}.tianditu.cn/img_c/wmts',
        label: {
          layerName: 'TDTLabel',
          layerType: 'TitleWMTS',
          layer: 'cia',
          alias: 'earth',
          isDefault: false,
          layerUrl: 'http://t{0-6}.tianditu.cn/cia_c/wmts'
        }
      },
      {
        layerName: 'panorama',
        layerType: 'TitleWMTS',
        layer: 'ter',
        isDefault: false,
        layerUrl: 'http://t{0-6}.tianditu.com/ter_c/wmts',
        label: {
          layerName: 'TDTLabel',
          layerType: 'TitleWMTS',
          layer: 'cia',
          alias: 'panorama',
          isDefault: false,
          layerUrl: 'http://t{0-6}.tianditu.cn/cia_c/wmts'
        }
      }
    ]
  });
  console.log(Maps);
</script>
</body>
</html>